package com.collectplus.express.home;

import android.app.Activity;
import android.content.Intent;
import android.os.Message;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.collectplus.express.BaseFragment;
import com.collectplus.express.MainActivity;
import com.collectplus.express.R;
import com.collectplus.express.logic.AppCache;
import com.collectplus.express.logic.AppHttp;
import com.collectplus.express.logic.AppLogic;
import com.collectplus.express.logic.AppResult;
import com.collectplus.express.logic.DialogMgr;
import com.collectplus.express.logic.JSON;
import com.collectplus.express.logic.MsgID;
import com.collectplus.express.model.AppConfigBean;
import com.collectplus.express.model.BannerBean;
import com.collectplus.express.model.CollectingPassportBean;
import com.collectplus.express.model.Const;
import com.collectplus.express.model.HomeNearServicePointBean;
import com.collectplus.express.model.PassportBean;
import com.collectplus.express.model.PassportDetailBean;
import com.collectplus.express.model.ServicePointBean;
import com.collectplus.express.parcel.ParcelSendActivity;
import com.collectplus.express.passport.PassportAdapter;
import com.collectplus.express.self.SelfFormInfoActivity;
import com.collectplus.express.view.OnTouchListenerExt;
import com.shouhuobao.bhi.collectpoint.ServicePointListActivity;
import com.shouhuobao.bhi.login.LoginActivity;
import com.shouhuobao.bhi.msgnotice.MsgNoticeActivity;
import com.shouhuobao.bhi.stamp.StampStoreActivity;
import com.shouhuobao.home.CalculatePriceActivity;
import com.shouhuobao.home.CallCenterOrderActivity;
import com.shouhuobao.samecity.SameCityFormActivity;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

import droid.frame.ui.dialog.AppDialog;
import droid.frame.umeng.UMeng;
import droid.frame.view.SwipeScrollViewViewPagerListener;
import droid.frame.view.ViewPagerExt;

/**
 * 新版首页、6.9元自助寄<br>
 *
 * @author coffee <br>
 * 2016-9-24上午9:43:48
 */
public class HomeFragment extends BaseFragment implements View.OnClickListener {//ViewTreeObserver.OnScrollChangedListener

    //    private View homePassportBottom = null;
    private int[] backColors = {R.drawable.passport_corners_top_3, R.drawable.passport_corners_top_4};
    private ScrollView scrollView = null;
    private ViewPagerExt mViewPager;
    // title 右侧的按钮
    private ImageView mNoticeRight;
    // viewPager下面的点点 layout
    private ViewGroup mStateLayout;

    private int scrollHeight = 200;
    //    private ArrayList<PassportBean> passportBeans = null;

    /**
     * 补差价包裹数量
     */
    private int needPayParcels;
    /**
     * 附近服务网点对象
     */
    private ServicePointBean servicePointBean = null;

    @Override
    protected void findViewById() {
        setContentView(R.layout.home);
        super.findViewById();
        // title右侧消息通知图片
        // int rightImage = R.drawable.title_notice_selector;
        AppConfigBean config = AppCache.getAppConfig();
        if (config != null && config.getMessageNum() > 0) {
            // rightImage = R.drawable.msg_notice_new;
        }
        Glide.with(getActivityContext()).load(R.drawable.samecity_image_gif).asGif().into((ImageView) findViewById(R.id.samecity_image_iv));
        Glide.with(getActivityContext()).load(R.drawable.self_image_gif).asGif().into((ImageView) findViewById(R.id.self_image_iv));
//        // 我要投递
//        View selfLayout = findViewById(R.id.home_69_layout);
//        selfLayout.setOnClickListener(this);
//        selfLayout.setOnTouchListener(new OnTouchListenerExt(getActivityContext()));
        //上门寄件
        View mVisitDoorLL = findViewById(R.id.visit_door_ll);
        mVisitDoorLL.setOnClickListener(this);
        mVisitDoorLL.setOnTouchListener(new OnTouchListenerExt(getActivityContext()));
        //快捷寄件通道
        View item1 = findViewById(R.id.home_item_1);
        item1.setOnClickListener(this);
        item1.setOnTouchListener(new OnTouchListenerExt(getActivityContext()));
        //服务网点
        View item2 = findViewById(R.id.home_item_2);
        item2.setOnClickListener(this);
        item2.setOnTouchListener(new OnTouchListenerExt(getActivityContext()));
        //运费计算器
        View item3 = findViewById(R.id.home_item_3);
        item3.setOnClickListener(this);
        item3.setOnTouchListener(new OnTouchListenerExt(getActivityContext()));
        // 邮票商场
        View item4 = findViewById(R.id.home_item_4);
        item4.setOnClickListener(this);
        item4.setOnTouchListener(new OnTouchListenerExt(getActivityContext()));

        // 登录
        findViewById(R.id.title_left_image).setOnClickListener(this);
        findViewById(R.id.title_right_image2).setOnClickListener(this);
        mNoticeRight = (ImageView) findViewById(R.id.title_right_image);
        mNoticeRight.setOnClickListener(this);
        //
        scrollView = (ScrollView) findViewById(R.id.scrollview);
        //        scrollView.getViewTreeObserver().addOnScrollChangedListener(this);
        mViewPager = (ViewPagerExt) findViewById(R.id.viewpager);
        SwipeScrollViewViewPagerListener listener = new SwipeScrollViewViewPagerListener(mSwipeLayout, scrollView);
        mViewPager.setOnTouchListener(listener);

        //        homePassportBottom = findViewById(R.id.home_passport_bottom);

        mStateLayout = (ViewGroup) findViewById(R.id.dot_layout);

        TextView mAfternoonTea1 = (TextView) findViewById(R.id.afternoon_tea1);
        TextView mAfternoonTea2 = (TextView) findViewById(R.id.afternoon_tea2);
        ImageView mHomeTime = (ImageView) findViewById(R.id.home_time_img);
        // 获取当时的时间
        SimpleDateFormat format24 = new SimpleDateFormat("HH");
        String str = format24.format(new java.util.Date());
        int hour = Integer.parseInt(str);
        int start = 0;// 起始时间0点
        int middle = 12;// 中午时间12点
        int end = 19;// 下午时间
        if (hour >= start && hour < middle) {
            // 0<h<=12
            mAfternoonTea1.setText("上午好");
            mAfternoonTea2.setText("GOODMORNING");
            mHomeTime.setImageResource(R.drawable.home_moring);
        } else if (hour == middle) {
            mAfternoonTea1.setText("中午好");
            mAfternoonTea2.setText("GOODNOON");
            mHomeTime.setImageResource(R.drawable.home_moring);
        } else if (hour > middle && hour <= end) {
            // 12<h<=19
            mAfternoonTea1.setText("下午好");
            mAfternoonTea2.setText("AFTERNOON");
            mHomeTime.setImageResource(R.drawable.home_afternoon);
        } else {
            mAfternoonTea1.setText("晚上好");
            mAfternoonTea2.setText("GOODEVENING");
            mHomeTime.setImageResource(R.drawable.home_evening);
        }

        //同城直送布局
        findViewById(R.id.samecity_layout_ll).setOnClickListener(this);
        // 设置默认的viewpager (俩图片)
        handleBanner(null);
        mViewPager.addOnPageChangeListener(mViewPager.new ViewPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                for (int i = 0; i < mViewPager.getChildCount(); i++) {
                    ImageView child = (ImageView) mStateLayout.getChildAt(i);
                    if (position == i) {
                        child.setImageResource(R.drawable.dot_light_2);
                    } else {
                        child.setImageResource(R.drawable.dot_dark_2);
                    }
                }
            }
        });
        //
        super.mSwipeLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh() {
                AppHttp.getInstance().getAppConfig(getActivityContext());
                AppHttp.getInstance().getAppBannerData(Const.BannerConfig.TOUDI_ANDROID_APP);
                AppHttp.getInstance().profile();
                ((MainActivity) getActivityContext()).requestLocation();
            }
        });
        // mSwipeLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light);
        // scrollView.getViewTreeObserver().addOnScrollChangedListener(new SwipeOnScrollChangedListener(mSwipeLayout, scrollView));
    }

    @Override
    public void onClick(View v) {
        Intent intent = null;
        switch (v.getId()) {
            // 我要投递
//            case R.id.home_69_layout:
//                AppConfigBean configBean = AppCache.getAppConfig();
//                if (configBean != null && configBean.isShowPop()) {
//                    DialogMgr.showSpringTips(getActivityContext());
//                }
//                // 调到投递袋寄件界面
//                if (needPayParcels > 0) {
//                    showUnpayedOrder();
//                } else {
//                    UMeng.click(getActivityContext(), "home_want_send_click");
//                    startActivity(SelfFormInfoActivity.class);
//                }
//                break;
            // 上门寄件
            case R.id.visit_door_ll:
                AppConfigBean configBean = AppCache.getAppConfig();
                if (configBean != null && configBean.isShowPop()) {
                    DialogMgr.showSpringTips(getActivityContext());
                }
                // 调到投递袋寄件界面
                if (needPayParcels > 0) {
                    showUnpayedOrder();
                } else {
                    startActivity(SelfFormInfoActivity.class);
                }
                break;
            //同城直送
            case R.id.samecity_layout_ll:
                startActivityWhenLogin(SameCityFormActivity.class);
                break;
            case R.id.home_item_1:// 快捷寄件通道
                startActivityWhenLogin(CallCenterOrderActivity.class);
                break;
            case R.id.home_item_2:// 服务网点
                startActivityWhenLogin(ServicePointListActivity.class);
                break;
            case R.id.home_item_3:// 运费计算器
                startActivityWhenLogin(CalculatePriceActivity.class);
                break;
            case R.id.home_item_4:// 邮票商场
                startActivityWhenLogin(StampStoreActivity.class);
                break;
            case R.id.title_right_image:// 登录和消息通知
                UMeng.click(getActivityContext(), "home_message_click");
                if (isLogin() == false) {
                    intent = new Intent();
                    intent.setClass(getActivityContext(), LoginActivity.class);
                    startActivity(intent);
                    return;
                }
                intent = new Intent();
                intent.setClass(getActivityContext(), MsgNoticeActivity.class);
                startActivityForResult(intent, 102);
                break;
            case R.id.title_right_image2:
                // 调到投递袋寄件界面
                HomeScanPopwin popwin = new HomeScanPopwin(this, needPayParcels);
                View scan = findViewById(R.id.title_right_image2);
                int[] location = new int[2];
                scan.getLocationOnScreen(location);
                int y = location[1] + scan.getHeight();
                int x = (int) (16 * getResources().getDisplayMetrics().density);
                popwin.showAtLocation(scan, Gravity.RIGHT | Gravity.TOP, x, y);
                break;
            case R.id.title_left_image:// 侧滑
                MainActivity fragment = (MainActivity) getActivity();
                fragment.openDrawer();
                UMeng.click(getActivityContext(), "home_left_click");
                break;
            default:
                break;
        }
    }

    /**
     * 补差价信息提示框
     */
    public void showUnpayedOrder() {
        final AppDialog dialog = new AppDialog(getActivityContext());
        StringBuilder sb = new StringBuilder();
        sb.append("您有" + needPayParcels + "个包裹超重,需要您补差价，在未补差价前,您将无法使用下单功能,请点击立即前往,或到我的包裹中查看详情");
        dialog.setContent(sb.toString());
        dialog.setConfirmClickListener("立即前往", new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivityContext(), ParcelSendActivity.class);
                intent.putExtra("item", 0);
                startActivity(intent);
                dialog.dismiss();
            }
        });
        dialog.setCancelClickListener("暂不处理", null);
        dialog.show();
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        // 去驿站投递包裹 (http://weixin.qq.com/q/j3XhTXjkafIQwi1xPVkk)
        if (requestCode == 101 && resultCode == Activity.RESULT_OK) {

        }
        // 查看通知 -- 设置通知图标
        else if (requestCode == 102 && resultCode == Activity.RESULT_OK) {
            // getTitleMgr().setTitleResource(R.drawable.title_notice_selector, 1, 2);
            mNoticeRight.setImageResource(R.drawable.title_notice_selector);
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }

    @Override
    public boolean handleMessage(Message msg) {
        switch (msg.what) {
            case MsgID.get_appConfig:
            case MsgID.get_app_banner_data:
                onRefreshComplete();
                return false;
            case MsgID.passport_detail:
                final AppResult<PassportDetailBean> result = JSON.parser(msg.obj, PassportDetailBean.class);
                cancelLoadingDialog();
                if (result.isSuccess()) {
                    PassportDetailBean passport = result.getResult();
                    if (passport != null && isResume) {
                        AppLogic.getInstance().showPassportDialog(getActivityContext(), passport, passport.getParcelId());
                    }
                    // getActivityContext().runOnUiThread(new Runnable() {
                    // @Override
                    // public void run() {
                    //                     AppLogic.getInstance().showPassportDialog(getActivityContext(), AppCache.getParcelId() + "");
                    // }
                    // });
                } else {
                    showToast(result.getMessage());
                }
                return false;
            case MsgID.passport_collecting_detail:
                cancelLoadingDialog();
                final AppResult<CollectingPassportBean> collectingResult = JSON.parser(msg.obj, CollectingPassportBean.class);
                if (collectingResult.isSuccess()) {
                    CollectingPassportBean passport = collectingResult.getResult();
                    if (passport != null && isResume) {
                        AppLogic.getInstance().showCollectingPassportDialog(getActivityContext(), passport, passport.getStationId(), passport.getTakeId());
                    }
                } else {
                    showToast(collectingResult.getMessage());
                }
                return false;
            // xmpp 新通知 - 通知图标改变
            case MsgID.msg_notice_new:
                return true;
            // 用户退出登录
            case MsgID.logout:
                handlePassport(null);
                return true;
            default:
                return super.handleMessage(msg);
        }
    }

    /**
     * 设置标题栏右侧按钮新消息提醒<订单状态提醒>
     */
    public void handleNewMsg() {
        AppConfigBean config = AppCache.getAppConfig();
        boolean isLogin = isLogin();
        //
        if (isLogin && config != null) {
            if (config.getMessageNum() > 0) {
                mNoticeRight.setImageResource(R.drawable.title_notice_new_selector);
            } else {
                mNoticeRight.setImageResource(R.drawable.title_notice_selector);
            }
        }
    }

    /**
     * 更新轮播图
     *
     * @param items
     */
    public void handleBanner(ArrayList<BannerBean> items) {
        if (mViewPager == null) {
            // 不作处理
        } else {
            BannerImageAdapter adapter = new BannerImageAdapter(items, getActivityContext());
            ArrayList<View> pages = new ArrayList<View>();
            for (int i = 0; i < adapter.getCount(); i++) {
                View child = adapter.getView(i, null, mViewPager);
                pages.add(child);
            }
            mViewPager.setOffscreenPageLimit(pages.size());
            mViewPager.setViewItems(pages, false);
            // viewpager下面的点点
            mStateLayout.setVisibility(View.VISIBLE);
            mStateLayout.removeAllViews();
            for (int i = 0; i < adapter.getCount(); i++) {
                ImageView child = (ImageView) LayoutInflater.from(getActivityContext()).inflate(R.layout.viewpager_dot, mStateLayout, false);
                if (i == 0) {
                    child.setImageResource(R.drawable.dot_light_2);
                } else {
                    child.setImageResource(R.drawable.dot_dark_2);
                }
                mStateLayout.addView(child);
            }
        }
    }

    /**
     * 处理passport
     *
     * @param items
     */
    public void handlePassport(ArrayList<PassportBean> items) {
        if (items == null || items.isEmpty()) {
            //            homePassportBottom.setVisibility(View.GONE);
            findViewById(R.id.passport_empty_layout).setVisibility(View.VISIBLE);
            findViewById(R.id.home_passport_parent_layout).setVisibility(View.GONE);
            return;
        }
        //        passportBeans = items;
        findViewById(R.id.passport_empty_layout).setVisibility(View.GONE);
        View homePassport = findViewById(R.id.home_passport_parent_layout);
        homePassport.setVisibility(View.VISIBLE);
        // passport卡包Layout
        final LinearLayout passportContainer = (LinearLayout) findViewById(R.id.home_passport_layout);
        final PassportAdapter adapter = new PassportAdapter(null, passportContainer);
        adapter.setItems(items, true);

        for (int i = 0; i < adapter.getCount(); i++) {
            View child = passportContainer.getChildAt(i);
            // 最上面那个元素 不需要设置marginTop
            if (i == 0) {
                LinearLayout.LayoutParams params = (LayoutParams) child.getLayoutParams();
                params.topMargin = 0;
                child.setLayoutParams(params);
            }
            final int position = i;
            child.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    PassportBean item = adapter.getItem(position);
                    showLoadingDialog("");
                    UMeng.click(getActivityContext(), "home_passport_click");
                    if (item.isTake()) {
                        AppHttp.getInstance().getPassportCollectingDetail(item.getStationId(), item.getTakeId());
                    } else {
                        AppHttp.getInstance().getPassportDetail(item.getParcelId(), 0);
                    }

                    //                    AppLogic.getInstance().showPassportDialog(getActivityContext(), item.getParcelId(), passportBeans, position);
                    // AppLogic.getInstance().showPassportDialog(getActivityContext(), item.getParcelId());
                }
            });
        }

        // passport数量
        TextView passportNum = (TextView) findViewById(R.id.home_passport_num);
        passportNum.setText(String.valueOf(adapter.getCount()));
        //设置悬浮的数据
        //        ImageView logo = (ImageView) findViewById(R.id.passport_logo);
        //        TextView send1 = (TextView) findViewById(R.id.send_code1);
        //        TextView send2 = (TextView) findViewById(R.id.send_code2);
        //        TextView recipients1 = (TextView) findViewById(R.id.parcel_recipients1);
        //        TextView recipients2 = (TextView) findViewById(R.id.parcel_recipients2);
        //        View codeItem = findViewById(R.id.code_item);
        //
        //        PassportBean item = adapter.getItem(0);
        //        send1.setText("寄件码");
        //        recipients1.setText(item.getReceiverCity());// 收件人城市
        //        recipients2.setText(item.getReceiverName());// 收件人
        //        if (Str.isEmpty(item.getCheckCode())) {
        //            send2.setText("000000");
        //            send2.setVisibility(View.INVISIBLE); // 设置不可见、主要为了控制宽度，使上面的"寄件码"文本对齐
        //        } else {
        //            send2.setText(item.getCheckCode());
        //            send2.setVisibility(View.VISIBLE);
        //        }
        //        if (item.getPassportStatus() != 1) {
        //            codeItem.setVisibility(View.INVISIBLE);
        //        }
        //        // 显示不同的图片背景
        //        int backgroudColor = 0;
        //        if (item.isCityWide()) {
        //            backgroudColor = backColors[0];
        //        } else {
        //            backgroudColor = backColors[1];
        //        }
        //        homePassportBottom.setBackgroundResource(backgroudColor);
        //
        //        if (item.getParcelType() == Const.ParcelType.standard//
        //                || item.getParcelType() == Const.ParcelType.bagToBox //
        //                || item.getParcelType() == Const.ParcelType.bagToHome) {
        //            logo.setImageResource(R.drawable.passport_top_logo);
        //            int color1 = getActivityContext().getResources().getColor(R.color.parcel_list_brown);
        //            send1.setTextColor(color1);
        //            send2.setTextColor(color1);
        //            recipients1.setTextColor(color1);
        //            recipients2.setTextColor(color1);
        //        } else {
        //            if (item.isCityWide()) {
        //                logo.setImageResource(R.drawable.passport_top_logo_black);
        //                int color2 = getActivityContext().getResources().getColor(R.color.app_fontcolor_333333);
        //                send1.setTextColor(color2);
        //                send2.setTextColor(color2);
        //                recipients1.setTextColor(color2);
        //                recipients2.setTextColor(color2);
        //            } else {
        //                logo.setImageResource(R.drawable.passport_top_logo_white);
        //                int color2 = getActivityContext().getResources().getColor(R.color.white);
        //                send1.setTextColor(color2);
        //                send2.setTextColor(color2);
        //                recipients1.setTextColor(color2);
        //                recipients2.setTextColor(color2);
        //            }
        //        }
    }

    /**
     * 处理未读消息数
     */
    public void handleNotice(AppConfigBean config) {
        if (mNoticeRight == null) {
            return;
        }
        if (config != null && config.getMessageNum() > 0) {
            mNoticeRight.setImageResource(R.drawable.title_notice_new_selector);
        } else {
            mNoticeRight.setImageResource(R.drawable.title_notice_selector);
        }
    }

    /**
     * 处理首页附近网点的数据
     *
     * @param pointBean
     */
    public void handleNearServicePoint(HomeNearServicePointBean pointBean) {
//        if (pointBean == null || !pointBean.isStatus()) {
//            //如果为空，不进行任何操作，展示没有开通驿站的布局
//            //没有开通驿站的布局
//            findViewById(R.id.home_no_service_point_iv).setVisibility(View.VISIBLE);
//            findViewById(R.id.no_service_point_tv).setVisibility(View.VISIBLE);
//            //附近没有驿站的布局
//            findViewById(R.id.go_near_service_point_iv).setVisibility(View.GONE);
//            findViewById(R.id.go_near_service_point_list_tv).setVisibility(View.GONE);
//            //附近有驿站的布局
//            findViewById(R.id.near_service_ponint_ll).setVisibility(View.GONE);
//            findViewById(R.id.home_item_4).setVisibility(View.GONE);
//            return;
//        } else {
//            servicePointBean = pointBean.getItem();
//            if (servicePointBean == null) {
//                //没有开通驿站的布局
//                findViewById(R.id.home_no_service_point_iv).setVisibility(View.GONE);
//                findViewById(R.id.no_service_point_tv).setVisibility(View.GONE);
//                //附近没有驿站的布局
//                findViewById(R.id.go_near_service_point_iv).setVisibility(View.VISIBLE);
//                View goNearServicePointList = findViewById(R.id.go_near_service_point_list_tv);
//                goNearServicePointList.setVisibility(View.VISIBLE);
//                goNearServicePointList.setOnClickListener(this);
//                goNearServicePointList.setOnTouchListener(new OnTouchListenerExt(getActivityContext()));
//                //附近有驿站的布局
//                findViewById(R.id.near_service_ponint_ll).setVisibility(View.GONE);
//                findViewById(R.id.home_item_4).setVisibility(View.GONE);
//            } else {
//                findViewById(R.id.home_no_service_point_iv).setVisibility(View.GONE);
//                findViewById(R.id.no_service_point_tv).setVisibility(View.GONE);
//                //附近没有驿站的布局
//                findViewById(R.id.go_near_service_point_iv).setVisibility(View.GONE);
//                findViewById(R.id.go_near_service_point_list_tv).setVisibility(View.GONE);
//                //附近有驿站的布局
//                findViewById(R.id.near_service_ponint_ll).setVisibility(View.VISIBLE);
//                findViewById(R.id.home_item_4).setVisibility(View.VISIBLE);
//                // 驿站
//                if (servicePointBean.isStation()) {
//                    if (Str.isEmpty(servicePointBean.getHeadImage())) {
//                        ((ImageView) findViewById(R.id.service_photo_iv)).setImageResource(R.drawable.service_point_logo2);
//                    } else {
//                        ImageView stationPhoto = (ImageView) findViewById(R.id.service_photo_iv);
//                        GlideUtil.loadImage(getActivityContext(), servicePointBean.getHeadImage(), 0, stationPhoto);
//                        stationPhoto.setOnClickListener(new View.OnClickListener() {
//                            @Override
//                            public void onClick(View v) {
//                                DialogMgr.showLargeStationPhoto(getActivityContext(), servicePointBean.getHeadImage());
//                            }
//                        });
//                    }
//                } else {
//                    ((ImageView) findViewById(R.id.service_photo_iv)).setImageResource(R.drawable.service_point_logo1);
//                }
//                ((TextView) findViewById(R.id.service_name_tv)).setText(servicePointBean.getName());
//                ((TextView) findViewById(R.id.distance_tv)).setText(servicePointBean.getDistance());
//                ((TextView) findViewById(R.id.service_address_tv)).setText(servicePointBean.getAddress());
//                String servicePointDesc = "<font color=#D1D1D1>附近500米内共</font><font color=#F5A623>{0}</font><font color=#D1D1D1>个投递点，查看全部</font>";
//                ((TextView) findViewById(R.id.near_service_desc_tv)).setText(Html.fromHtml(MessageFormat.format(servicePointDesc, pointBean.getNum())));
//                //跳转到服务网点详情
//                View item5 = findViewById(R.id.home_station_ll);
//                item5.setOnClickListener(this);
//                item5.setOnTouchListener(new OnTouchListenerExt(getActivityContext()));
//                //服务网点列表
//                View item4 = findViewById(R.id.home_item_4);
//                item4.setOnClickListener(this);
//                item4.setOnTouchListener(new OnTouchListenerExt(getActivityContext()));
//            }
//        }
//
    }

    public void setNeedPayParcels(int needPayParcels) {
        this.needPayParcels = needPayParcels;
    }

    //    @Override
    //    public void onScrollChanged() {
    //        int y = scrollView.getScrollY();
    //        if (y > scrollHeight) {
    //            homePassportBottom.setVisibility(View.GONE);
    //        } else {
    //            homePassportBottom.setVisibility(View.VISIBLE);
    //        }
    //    }
}
